package com.centaline.androidsalesblog.fragments;


import android.content.Intent;
import android.support.v7.widget.AppCompatTextView;
import android.view.View;

import com.centaline.androidsalesblog.R;
import com.centaline.androidsalesblog.activities.entrust.EntrustActivity;
import com.centaline.androidsalesblog.activities.entrust.MyHouseResourceActivity;
import com.centaline.androidsalesblog.activities.entrust.ReservationListActivity;
import com.centaline.androidsalesblog.base.BaseFragment;
import com.centaline.androidsalesblog.constants.ExtraConstant;


/**
 * 委托
 */
public class EntrustFragment extends BaseFragment implements View.OnClickListener {

    private AppCompatTextView atv_entrust_sale_rent, atv_entrust_my_house,
            atv_entrust_order, atv_my_reservation_list;

    @Override
    protected int setLayoutId() {
        return R.layout.fragment_entrust;
    }

    @Override
    protected void findViews(View view) {
        atv_entrust_sale_rent = (AppCompatTextView) view.findViewById(R.id.atv_entrust_sale_rent);
        atv_entrust_my_house = (AppCompatTextView) view.findViewById(R.id.atv_entrust_my_house);
        atv_entrust_order = (AppCompatTextView) view.findViewById(R.id.atv_entrust_order);
        atv_my_reservation_list = (AppCompatTextView) view.findViewById(R.id.atv_my_reservation_list);
    }

    @Override
    protected void initView() {
        atv_entrust_sale_rent.setOnClickListener(this);
        atv_entrust_my_house.setOnClickListener(this);
        atv_entrust_order.setOnClickListener(this);
        atv_my_reservation_list.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            //我要约看
            case R.id.atv_entrust_order:
                startActivity(new Intent(getActivity(), ReservationListActivity.class)
                        .putExtra(ExtraConstant.EXTRA_POSITION, 0));
                break;
            //委托租售
            case R.id.atv_entrust_sale_rent:
                startActivity(new Intent(getActivity(), EntrustActivity.class));
                break;
            //查看我的房源
            case R.id.atv_entrust_my_house:
                startActivity(new Intent(getActivity(), MyHouseResourceActivity.class));
                break;
            //查看我的约看单
            case R.id.atv_my_reservation_list:
                startActivity(new Intent(getActivity(), ReservationListActivity.class)
                        .putExtra(ExtraConstant.EXTRA_POSITION, 1));
                break;
            default:
                break;
        }
    }
}

